#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <string.h>


int main(int argc,char* argv[])
{
  int udp_fd = socket(AF_INET,SOCK_DGRAM,0);
  if(udp_fd < 0)
  {
    perror("socket fail");
    exit(-1);
  }
  
  char buf[1024] = {0};

  struct sockaddr_in send_addr;
  send_addr.sin_port = htons(50000);
  send_addr.sin_family = AF_INET;
  inet_pton(AF_INET,argv[1],&send_addr.sin_addr);

  while(1)
  {
    memset(buf,0,1024);
    printf("please input:\n");
    fgets(buf,1024,stdin);

    sendto(udp_fd,&buf,strlen(buf),0,(struct sockaddr*)&send_addr,sizeof(send_addr));
  }

  return 0;
}

